import request from '../../utils/Request'
import PageUtils from '../../utils/PageUtils'

export const saveDatabase = data => {
  return request({
    method: 'post',
    url: '/api/monitor/database/save',
    data: data
  })
}

export const createDatabase = (data, idempotentCode) => {
  return request({
    method: 'post',
    url: '/api/monitor/database/create',
    data: data,
    headers: {
      common: {
        idempotent: idempotentCode
      }
    }
  })
}

export const updateDatabase = data => {
  return request({
    method: 'post',
    url: '/api/monitor/database/update',
    data: data
  })
}

export const updateDatabaseStatus = (databaseId, status) => {
  return request({
    method: 'get',
    url: '/api/monitor/database/' + databaseId + '/status/' + status,
    params: {}
  })
}

export const deleteDatabase = bId => {
  return request({
    method: 'get',
    url: '/api/monitor/database/delete/' + bId,
    params: {}
  })
}

export const listDatabase = (data, current, size) => {
  let pageUrl = PageUtils.page(current, size)
  return request({
    method: 'get',
    url: '/api/monitor/database/list?' + pageUrl,
    params: data
  })
}

export const selectDatabase = bId => {
  return request({
    method: 'get',
    url: '/api/monitor/database/select/' + bId,
    params: {}
  })
}